package com.abigdreamer.im.client.module.talk;

import com.abigdreamer.im.client.module.messageProcess.IMessageProcess;
import com.abigdreamer.im.client.module.vo.Cache;
import com.abigdreamer.im.client.ui.trayIcon.EIMTrayIcon;
import com.abigdreamer.im.message.BaseMessage;
import com.abigdreamer.im.message.TalkMessage;

public class TalkMessageProcess implements IMessageProcess {

	public void processMessage(BaseMessage message) {
		final TalkMessage talkMessage = (TalkMessage) message;
		final String friendQQ = message.getSrcQQ();

		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				Cache cache = Cache.getInstance();
				TalkWindow qqTalkFrame = cache.getTalkFrame(friendQQ);
				EIMTrayIcon trayIcon = EIMTrayIcon.getInStance();
				qqTalkFrame.showMsg(qqTalkFrame.friend.getUserName(), talkMessage.getTalkMsg());
				if (!qqTalkFrame.isVisible()) {
					trayIcon.addRevedMessage(talkMessage);
					trayIcon.showIcon(talkMessage.getMsgType());
					trayIcon.setGetMsg(true);
				}
			}
		});

	}
}
